package com.yb.oldlearning;

import java.util.concurrent.TimeUnit;

public class SimpleDaemons implements Runnable{
	public void run(){
		while(true){
			try {
				TimeUnit.MILLISECONDS.sleep(175);
				System.out.println(Thread.currentThread() + " " + this);
			} catch (InterruptedException e) {
				System.out.println("sleep() Interrupted");
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) throws InterruptedException {
		for(int i=0; i< 10; i++){
			Thread thread = new Thread(new SimpleDaemons());
			thread.setDaemon(true);//设置为后台进程
			thread.start();
		}
		System.out.println("all daemons started");
		TimeUnit.MILLISECONDS.sleep(175);
	}
}
